package org.example.sep_24;

import java.util.Stack;

public class Topic_67 {
    public static void main(String[] args) {
        new Topic_67().addBinary("1000","1010");
    }
    public String addBinary(String a, String b) {
        int al = a.length();
        int bl = b.length();
        Stack<Character> numA = strToNum(a,al);
        Stack<Character> numB = strToNum(b,bl);
        int t = 0;
        StringBuilder sb = new StringBuilder();
        while(!numA.isEmpty() || !numB.isEmpty() || t == 1) {
            char aChar = numA.isEmpty() ? '0' : numA.pop();
            char bChar = numB.isEmpty() ? '0' : numB.pop();
            if (t == 0)
                if((aChar == '0' && bChar == '1')||(aChar == '1' && bChar == '0')) {
                    sb.append(1);
                } else if (aChar == '1' && bChar == '1') {
                    t = 1;
                }
        }
        return "0";
    }
    private Stack<Character> strToNum(String a,int n){
        Stack<Character> stack = new Stack<>();
        for(int i = 0;i < n;i++){
            stack.push(a.charAt(i));
        }
        return stack;
    }
}
